package operation;

import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-17
 * Time: 8:51
 */
public class LendOperation implements Operation{
    @Override
    public void work(BookList booklist) {
        System.out.println("借阅书籍");
        System.out.println("请输入要借阅书籍的名称：");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        int cursize = booklist.getBooksize();
        for (int i = 0; i < cursize; i++) {
            if( booklist.getBooks(i).getName().equals(name)) {
                booklist.getBooks(i).setIsborrow(true);
                System.out.println("借阅成功！");
                return ;
            }
        }
        System.out.println("要借阅的书籍不存在!");
    }
}
